syntax = "proto3";

package kuma.mesh.v1alpha1;

option go_package = "github.com/kumahq/kuma/api/mesh/v1alpha1";

import "api/mesh/options.proto";

// MeshInsight defines the observed state of a Mesh.
message MeshInsight {

  option (kuma.mesh.resource).name = "MeshInsightResource";
  option (kuma.mesh.resource).type = "MeshInsight";
  option (kuma.mesh.resource).global = true;
  option (kuma.mesh.resource).package = "mesh";
  option (kuma.mesh.resource).ws.name = "mesh-insight";
  option (kuma.mesh.resource).ws.read_only = true;

  reserved 1; // formerly last_sync

  // DataplaneStat defines statistic specifically for Dataplane
  message DataplaneStat {
    uint32 total = 1;
    uint32 online = 2;
    uint32 offline = 3;
    uint32 partially_degraded = 4;
  }
  DataplaneStat dataplanes = 2;

  // PolicyStat defines statistic for all policies in general
  message PolicyStat { uint32 total = 1; }
  map<string, PolicyStat> policies = 3;

  // DpVersions defines statistics grouped by dataplane versions
  message DpVersions {

    // Dataplane stats grouped by KumaDP version
    map<string, DataplaneStat> kumaDp = 1;

    // Dataplane stats grouped by Envoy version
    map<string, DataplaneStat> envoy = 2;
  }
  DpVersions dpVersions = 4;

  message MTLS {
    // Dataplanes grouped by issued backends.
    map<string, DataplaneStat> issuedBackends = 1;
    // Dataplanes grouped by supported backends.
    map<string, DataplaneStat> supportedBackends = 2;
  }

  // mTLS statistics
  MTLS mTLS = 5;

  // ServiceStat defines statistics of mesh services
  message ServiceStat {
    uint32 total = 1;
    uint32 internal = 2;
    uint32 external = 3;
  }
  ServiceStat services = 6;

  // DataplanesByType defines statistics splitted by dataplane types
  message DataplanesByType {
    DataplaneStat standard = 1;
    DataplaneStat gateway = 2;
    DataplaneStat gatewayBuiltin = 3;
    DataplaneStat gatewayDelegated = 4;
  }
  DataplanesByType dataplanesByType = 7;
}
